using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.Diagnostics;
using WozLib.Net;

namespace WozLib.UI.Ink.SketchCommands
{
  public class PlayAudioSketchCommand : SketchCommand
  {
    
    [XmlAttribute("FileToPlay")]
    public string FileToPlay
    {
      get { return _FileToPlay; }
      set { _FileToPlay = value; }
    } private string _FileToPlay;


    public PlayAudioSketchCommand()
    {
    }

    public PlayAudioSketchCommand(string fileToPlay)
      : base()
    {
      FileToPlay = fileToPlay;
    }

    public override void Redo()
    {
      try
      {
        if (FileToPlay != null && FileToPlay.Length > 0)
        {
          System.Media.SoundPlayer s = new System.Media.SoundPlayer(HttpFileServer.GetRemoteFileUrl(FileToPlay));
          s.Play();
        }
      }
      catch (Exception ex)
      {
        Debug.WriteLine(ex.ToString());
      }
    }

    public override void Undo()
    {
      // can't undo audio playing
    }
  }
}
